#include <stdio.h>
int countdigit(long long int number,int digit);
int main(void){
    long long int m,n,S;
    int countdigit(long long int number,int digit);
    scanf("%d",&m);
    if(m<0)
        m=-m;
    S= countdigit(m,n);
    printf("%d",S);
    return 0
}
int countdigit(long long int number,int digit){
    int i,result=0;
    while(number>0){
        i=number%10;
        number=number/10;
        if(i==digit)
            result++;
    }
    return result;
}